package com.tanyin.demo.entity;

import lombok.Data;

/**
 * @author xdf
 */
@Data
public class CommonResult {

    private Integer code;

    private String message;

    private Boolean success;

    private Object data;

    public static CommonResult success() {
        CommonResult commonResult = new CommonResult();
        commonResult.setCode(200);
        commonResult.setSuccess(true);
        commonResult.setMessage("Success!");
        return commonResult;
    }

    public static CommonResult success(Object data) {
        CommonResult commonResult = new CommonResult();
        commonResult.setCode(200);
        commonResult.setSuccess(true);
        commonResult.setMessage("Success!");
        commonResult.setData(data);
        return commonResult;
    }

    public static CommonResult fail(Object data,String message) {
        CommonResult commonResult = new CommonResult();
        commonResult.setCode(400);
        commonResult.setSuccess(false);
        commonResult.setMessage(message);
        commonResult.setData(data);
        return commonResult;
    }
}
